/*
 * Generated file. 
 * 
 * Mobile_005fnewTopic.java
 */
package xsp;

import com.ibm.xsp.page.compiled.AbstractCompiledPage;
import com.ibm.xsp.page.compiled.AbstractCompiledPageDispatcher;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import com.ibm.xsp.page.compiled.NoSuchComponentException;
import com.ibm.xsp.page.compiled.PageExpressionEvaluator;
import java.lang.String;
import java.lang.Object;
import java.lang.Integer;
import com.ibm.xsp.component.UIViewRootEx2;
import com.ibm.xsp.component.UIPanelEx;
import com.ibm.xsp.model.domino.DominoDocumentData;
import javax.faces.el.MethodBinding;
import java.lang.Boolean;
import com.ibm.xsp.extlib.component.mobile.UIDMHeading;
import com.ibm.xsp.extlib.component.mobile.UIToolBarButton;
import com.ibm.xsp.component.xp.XspEventHandler;
import com.ibm.xsp.extlib.actions.MoveToAction;
import javax.faces.el.ValueBinding;
import com.ibm.xsp.extlib.component.data.UIFormTable;
import com.ibm.xsp.extlib.component.data.UIFormLayoutRow;
import com.ibm.xsp.component.xp.XspInputText;
import com.ibm.xsp.component.xp.XspInputTextarea;

@SuppressWarnings("all")
public class Mobile_005fnewTopic extends AbstractCompiledPageDispatcher{

    private static final String[][] s_libraryVersions = new String[][]{
        {"com.ibm.xsp.extlib.library", "8.5.32006"},  // version of "xe:toolBarButton"
    };
    
    public Mobile_005fnewTopic() {
        super("8.5.1"); // version of xp:inputTextarea htmlFilter
    }

    protected String[][] getLibraryTagVersions() {
        return s_libraryVersions;
    }

    protected AbstractCompiledPage createPage(int pageIndex) {
        return new Mobile_005fnewTopicPage();
    }
    
    protected boolean isCustomControl() {
        return true;
    }

    public static class Mobile_005fnewTopicPage extends AbstractCompiledPage {
        
        private static final ComponentInfo[] s_infos = new ComponentInfo[]{
            ComponentInfo.EMPTY_NORMAL, // 0 eventHandler
            new ComponentInfo(false, new int[]{0}), // 1 "button2"
            new ComponentInfo(false, null, // 2 "djxmheading3"
              new Object[][]{
                new Object[]{"actionFacet", Integer.valueOf(1)},
              } ),
            ComponentInfo.EMPTY_NORMAL, // 3 "inputtext1"
            new ComponentInfo(false, new int[]{3}), // 4 "formrow1"
            ComponentInfo.EMPTY_NORMAL, // 5 "inputtext2"
            new ComponentInfo(false, new int[]{5}), // 6 "formrow2"
            ComponentInfo.EMPTY_NORMAL, // 7 "documentbody"
            new ComponentInfo(false, new int[]{7}), // 8 "formrow8"
            new ComponentInfo(false, new int[]{4, 6, 8}), // 9 "formtable2"
            new ComponentInfo(false, new int[]{2, 9}), // 10 panel
            new ComponentInfo(false, new int[]{10}), // 11 view
        };
        
        public Mobile_005fnewTopicPage() {
            super(11, s_infos );
        }
        
        public int getComponentForId(String id) throws NoSuchComponentException { 
            if( "djxmheading3".equals(id) )
                return 2;
            if( "button2".equals(id) )
                return 1;
            if( "formtable2".equals(id) )
                return 9;
            if( "formrow1".equals(id) )
                return 4;
            if( "inputtext1".equals(id) )
                return 3;
            if( "formrow2".equals(id) )
                return 6;
            if( "inputtext2".equals(id) )
                return 5;
            if( "formrow8".equals(id) )
                return 8;
            if( "documentbody".equals(id) )
                return 7;
            return -1;
        }
        
        public UIComponent createComponent(int id, FacesContext context,
                UIComponent parent, PageExpressionEvaluator evaluator)
                throws NoSuchComponentException { 
            switch (id) {
            case 11:
                return createView(context, parent, evaluator);
            case 10:
                return createPanel(context, parent, evaluator);
            case 2:
                return createDjxmheading3(context, parent, evaluator);
            case 1:
                return createButton2(context, parent, evaluator);
            case 0:
                return createEventHandler(context, parent, evaluator);
            case 9:
                return createFormtable2(context, parent, evaluator);
            case 4:
                return createFormrow1(context, parent, evaluator);
            case 3:
                return createInputtext1(context, parent, evaluator);
            case 6:
                return createFormrow2(context, parent, evaluator);
            case 5:
                return createInputtext2(context, parent, evaluator);
            case 8:
                return createFormrow8(context, parent, evaluator);
            case 7:
                return createDocumentbody(context, parent, evaluator);
            }
            throw new NoSuchComponentException(id);
        }
        
        private UIComponent createView(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIViewRootEx2 result = new UIViewRootEx2();
            initViewRoot(result);
            return result;
        }

        private UIComponent createPanel(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIPanelEx result = new UIPanelEx();
            DominoDocumentData data = new DominoDocumentData();
            data.setComponent(result);
            String sourceId = "/xp:view[1]/xp:panel[1]/xp:this.data[1]/xp:dominoDocument[1]/xp:this.querySaveDocument[1]/text()";
            MethodBinding querySaveDocument = evaluator.createMethodBinding(result,
                    "#{javascript:// store user CGI variables\n\t\t\t\t\t\tvar cgi = new CGIVariables();\n\t\t\t\t\t\tdominoDoc.replaceItemValue(\"Remote_User\", cgi.get(\"REMOTE_USER\"));\n\t\t\t\t\t\tdominoDoc.replaceItemValue(\"Remote_Addr\", cgi.get(\"REMOTE_ADDR\"));\n\t\t\t\t\t\tcgi = null;\n\t\t\t\t\t}",
                    null,null, sourceId);
            data.setQuerySaveDocument(querySaveDocument);
            data.setComputeWithForm("onsave");
            data.setAction("newDocument");
            data.setVar("dominoDoc");
            data.setFormName("MainTopic");
            result.addData(data);
            return result;
        }

        private UIComponent createDjxmheading3(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            // loaded=??
            String loadedBnd = "#{javascript:isMobile()}";
            String sourceId = "djxmHeading3/@loaded";
            String loaded = evaluator.evaluateAsString(null, loadedBnd, sourceId, boolean.class);
            if ( null != loaded && loaded.length() > 0 &&
                    ! Boolean.parseBoolean(loaded) ) {
                return null;
            } // else loaded was true
            UIDMHeading result = new UIDMHeading();
            result.setLabel("New Topic");
            result.setBack("Cancel");
            setId(result, "djxmHeading3");
            result.setMoveTo("home");
            return result;
        }

        private UIComponent createButton2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIToolBarButton result = new UIToolBarButton();
            result.setLabel("Save");
            setId(result, "button2");
            return result;
        }

        private UIComponent createEventHandler(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspEventHandler result = new XspEventHandler();
            MoveToAction action = new MoveToAction();
            action.setComponent(result);
            String sourceId = "button2/xp:eventHandler[1]/xp:this.action[1]/xe:moveTo[1]/@targetPage";
            String targetPageExpr = "#{javascript:sessionScope.from}";
            ValueBinding targetPage = evaluator.createValueBinding(result, targetPageExpr, sourceId,String.class);
            action.setValueBinding("targetPage", targetPage);
            action.setForceFullRefresh(true);
            action.setSaveDocument(true);
            action.setTransitionType("slide");
            action.setDirection("Left to Right");
            action.setSourceReferenceId("button2/xp:eventHandler[1]/xp:this.action[1]/xe:moveTo[1]");
            result.setAction(action);
            result.setSubmit(true);
            result.setEvent("onclick");
            result.setRefreshMode("complete");
            return result;
        }

        private UIComponent createFormtable2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIFormTable result = new UIFormTable();
            result.setFormTitle(" ");
            setId(result, "formTable2");
            return result;
        }

        private UIComponent createFormrow1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIFormLayoutRow result = new UIFormLayoutRow();
            result.setLabel("Subject");
            setId(result, "formRow1");
            return result;
        }

        private UIComponent createInputtext1(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspInputText result = new XspInputText();
            String sourceId = "inputText1/@value";
            String valueExpr = "#{dominoDoc.Subject}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            result.setStyleClass("mblFormRowInput");
            setId(result, "inputText1");
            result.setRequired(true);
            return result;
        }

        private UIComponent createFormrow2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIFormLayoutRow result = new UIFormLayoutRow();
            result.setLabel("Tags");
            setId(result, "formRow2");
            return result;
        }

        private UIComponent createInputtext2(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspInputText result = new XspInputText();
            String sourceId = "inputText2/@value";
            String valueExpr = "#{dominoDoc.WebCategories}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            result.setMultipleSeparator(",");
            result.setStyleClass("mblFormRowInput");
            setId(result, "inputText2");
            return result;
        }

        private UIComponent createFormrow8(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            UIFormLayoutRow result = new UIFormLayoutRow();
            setId(result, "formRow8");
            result.setLabelPosition("left");
            return result;
        }

        private UIComponent createDocumentbody(FacesContext context, 
                UIComponent parent, PageExpressionEvaluator evaluator) {
            XspInputTextarea result = new XspInputTextarea();
            String sourceId = "documentBody/@value";
            String valueExpr = "#{dominoDoc.Body}";
            ValueBinding value = evaluator.createValueBinding(result, valueExpr, sourceId,Object.class);
            result.setValueBinding("value", value);
            result.setHtmlFilter("acf");
            result.setStyleClass("mblFormRowTextArea");
            result.setHtmlFilterIn("acf");
            result.setRows(5);
            setId(result, "documentBody");
            return result;
        }

    }
}
